<template>
	<view class="my-content-info">
		<view class="list">
			<view class="li-box" v-for="(item,index) in DescList" :key="index">
				<view class="li-item">
					<view class="left"><u--image :src="shopMallImgUrl+'vipGift.png'" width="96rpx"
							height="96rpx"></u--image></view>
					<view class="middle">
						<view class="big-tit">{{item.name}}</view>
						<view class="small-tit" v-if="item.value==false">未开启，点击右方按钮开启</view>
						<view class="small-tit" v-if="item.value==true">已开启{{item.name}}</view>
					</view>
					<view class="right"><u-switch v-model="item.value" @change="changeOne(item.payType,index)" size="20"
							activeColor="#FF1C60"></u-switch></view>
				</view>
				<view class="li-word">
				{{item.desc}}
				</view>
			</view>
		
		</view>
		<u-modal :show="show" title="提示" :content='content' :showCancelButton="true" confirmColor="#FF1C60"
			@confirm="sureSubmit" @cancel="closeSub"></u-modal>
	</view>
</template>

<script>
	import {
		shopMallImgUrl
	} from "@/common/config.js"
	import {
		getStoreData,
		dealNum,
		setStoreData,
		httpPost,
		httpGet,
	} from "@/utils/http.js";
	const pic1 = require(`@/img/my/my1.png`);
	const avatar = require(`@/img/my/avatar1.jpg`);
	export default {
		data() {
			return {
				shopMallImgUrl: shopMallImgUrl,
				list: [],
				show: false,
				content: "会员订单开启后7天内不能取消",
				type: null,
				benefitInfo: {
					orderType: "",
					status: 1,//1未开启，0开启
					storePayChannelDescList:[],
					value:false//未开启
				},
				DescList:[],
				typeIndex:null

			};
		},
		onLoad() {
			this.userInfo = getStoreData("userInfo");
			this.getSetList();

		},
		onShow() {
			
		},
		methods: {
			
			changeOne(e,i) {
				console.log(e,i)
				this.typeIndex=i;
				this.type=e;
				if (this.DescList[i].value) {
					this.show = true;
				} else {
					this.show = false;
					this.sureSubmit();
				}
			},
			

			open() {
				this.show = true;
			},
			sureSubmit() {
				let that = this;
				httpGet("/api/sellerunionconfig/updateInfo/"+this.type).then((res) => {
					console.log(99,res)
						that.show = false;
						that.getSetList();
					})
					.catch((e) => {
						console.log(33,e)
						that.show = false;
						that.reduction();
						that.getSetList();
					});
			
			},
			reduction(){
				this.DescList[this.typeIndex].value=!this.DescList[this.typeIndex].value;
			},
			closeSub() {
				this.show = false;
				this.reduction();
				this.getSetList();
			},
			getSetList() {
				let that = this;
				httpGet("/api/sellerunionconfig/info")
					.then((res) => {
						that.benefitInfo = res.data;
						if(res.data.storePayChannelDescList.length>0){
							that.DescList=res.data.storePayChannelDescList.map((item,index)=>{
								if(res.data.orderType==item.payType&&res.data.status==0){
									item.value=true;
								}else{
									item.value=false;
								}
								return item;
							});
						}
						
						
					})
					.catch((e) => {});
			}




		},
	};
</script>

<style lang="scss">
	.my-content-info {
		background-color: #F7F7F7;
		height: calc(100vh - 44px);
		padding-top: 20rpx;
	}

	.list {
		.li-box {
			background-color: #fff;
			border-radius: 10rpx;
			margin-left: 30rpx;
			margin-right: 30rpx;
			padding: 30rpx;
			margin-bottom: 20rpx;
		}

		.li-item {
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.middle {
				width: 410rpx;

				.big-tit {
					font-size: 32rpx;
					font-weight: bold;
				}

				.small-tit {
					font-size: 28rpx;
					color: #AAAAAA;
				}
			}

			.right {
				padding-top: 24rpx;
			}
		}

		.li-word {
			font-size: 24rpx;
			margin-top: 20rpx;
			background-color: #fddce4;
			color: #FF2F61;
			padding: 20rpx;
			border-radius: 10rpx;
		}
	}

	.agreement {
		padding: 30rpx;

		.tit {
			font-size: 36rpx;
			font-weight: bold;
			text-align: center;
			margin-bottom: 30rpx;
		}

		.btn {
			height: 70rpx;
			width: 100%;
			border-radius: 10rpx;
			background: linear-gradient(to right, #00A8FF, #11E4BF);
			line-height: 70rpx;
			text-align: center;
			color: #fff;
			margin-top: 30rpx;
		}
	}
</style>